# $Id: PKGBUILD 178994 2013-03-01 10:25:10Z andrea $
# Contributor: Ronald van Haren <ronald.archlinux.org>
# Contributor: tobias <tobias@archlinux.org>
# Contributor: Ben <ben@benmazer.net>
# Maintainer: Daniel J Griffiths <ghost1227@archlinux.us>

pkgname=scribus
pkgver=1.4.2
pkgrel=2
pkgdesc="A desktop publishing program"
arch=('i686' 'x86_64')
url="http://www.scribus.net"
license=('GPL')
install=scribus.install
depends=('libcups>=1.3.11' 'lcms2' 'qt4' 'ghostscript>=8.70' \
         'libart-lgpl>=2.3.20' 'python2' 'libxml2>=2.7.3' 'cairo' \
         'desktop-file-utils' 'shared-mime-info' \
         'hyphen' 'aspell' 'boost-libs')
makedepends=('cmake' 'boost' 'mesa')
options=(!libtool)
source=(http://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.xz)
sha1sums=('6e67e98fa315a2890d9cbb12eed49ecebb7f11cb')

build() {
	cd "${srcdir}"

	sed -i -e 's|#!/usr/bin/python|#!/usr/bin/python2|' \
	       -e 's|#!/usr/bin/env python|#!/usr/bin/env python2|' \
               scribus-${pkgver}/scribus/plugins/scriptplugin/{samples,scripts}/*

	mkdir build
	cd build
	cmake ../scribus-${pkgver} \
	   -DCMAKE_INSTALL_PREFIX=/usr \
	   -DCMAKE_BUILD_TYPE=Release \
	   -DCMAKE_SKIP_RPATH=ON \
	   -DWANT_CAIRO=1 \
	   -DLIB_SUFFIX=""
	make
}

package() {
	cd "${srcdir}/build"
	make DESTDIR="${pkgdir}" install

	# fix icon path in .desktop file
	sed -i 's|Icon=scribus|Icon=/usr/share/scribus/icons/scribus.png|' \
	   "${srcdir}/scribus-${pkgver}/scribus.desktop"

	install -Dm644 "${srcdir}/scribus-${pkgver}/scribus.desktop" \
	   "${pkgdir}/usr/share/applications/scribus.desktop"
}
